<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <!--{include file='comm/header.tpl'}-->
    <title>澳粒退货单列表</title>
    <!--{include file='comm/comm_cal.tpl'}-->
</head>
<body>

<!--{include file='comm/naviBanner.tpl'}-->

<div class="container">

    <!--{include file='comm/menu.tpl'}-->

    <div class="comm_crub">
        <span class="now_crub">澳粒退货单列表</span>
    </div>

    <div class="comm_content">

            <div class="search-box">
                <div style="position:relative">
                    <form class="form-inline" id="search_form" onsubmit="return false;">
                        <input type="hidden" name="billPlatform" value="2"/>
                        <table>
                            <tbody>
                            <tr>
                                <td>
                                    <span>退货单编号：<input type="text" class="form-control w150" name="return_no"></span>
                                    <span>订单编号：<input type="text" class="form-control w150" name="bill_code"></span>
                                    <span>会员名：<input type="text" class="form-control w150" name="custID"></span>
                                    <span>
                                        退货原因：<select class="form-control" id="second_id" name="return_reason_id_1" style="width: 200px;margin-right: 10px;">
                                            <option value="">请选择</option>
                                        </select>
                                        <select class="form-control" id="third_id" name="return_reason_id_2" style="width: 200px;">
                                            <option value="">请选择</option>
                                        </select>
                                    </span>
                                    <span>
                                        退货单状态：<select class="form-control" id="return_status" name="return_status">
                                            <option value="-1">请选择</option>
                                            <option value="1">未审核</option>
                                            <option value="2">已审核</option>
                                            <option value="3">已收货</option>
                                            <option value="4">已取消</option>
                                        </select>
                                    </span>
                                    <span>
                                        配送站：<select class="form-control" id="distribution_id" name="distribution_id">
                                            <option value="">请选择</option>
                                            <!--{foreach from=$distribution_array item=value}-->
                                            <option value="<!--{$value.distribution_id}-->"><!--{$value.distribution_name}--></option>
                                            <!--{/foreach}-->
                                        </select>
                                    </span>
                                    <span>
                                        配送日期：
                                        <input class="form-control w100" id="sendDate" name="sendDate" value="" readonly="readonly" type="text" />
                                        <button type="button" class="btn btn-default btn-sm" onclick="bill.timeClear3();">清 空</button>
                                    </span>
                                    <span>
                                        创建日期：
                                        <input class="form-control w100" id="startDate" name="startDate" value="" readonly="readonly" type="text" />
                                        ～
                                        <input class="form-control w100" id="endDate" name="endDate" value="" readonly="readonly" type="text" />
                                        <button type="button" class="btn btn-default btn-sm" onclick="bill.timeClear1();">清 空</button>
                                    </span>
                                    <span>
                                        审核日期：
                                        <input class="form-control w100" id="auditStartDate" name="auditStartDate" value="" readonly="readonly" type="text" />
                                        ～
                                        <input class="form-control w100" id="auditEndDate" name="auditEndDate" value="" readonly="readonly" type="text" />
                                        <button type="button" class="btn btn-default btn-sm" onclick="bill.timeClear2();">清 空</button>
                                    </span>

                                    <span>
                                        备注：<input type="text" class="form-control w300" name="return_memo">
                                    </span>

                                    <span>
                                        <button type="button" class="btn btn-primary" onclick="bill.search();">查 询</button>&nbsp;&nbsp;
                                        <button type="button" class="btn btn-warning" onclick="bill.clear();">重 置</button>
                                    </span>

                                </td>
                            </tr>

                            </tbody>
                        </table>
                    </form>
                </div>
            </div>

            <table id="flex" style="display:none"></table>

        </div>

    

</div>

<script type="text/javascript">

$("#flex").flexigrid({
    url:"/invokingAjax-backend/bill/billReturn.ajax?operFlg=1&xjx=none",
    dataType: "json",
    colModel : [
        {display: "操作", width : 100, align: "center"},
        {display: "状态", width : 70, align: "center"},
        {display: "退货单编号", name : "return_no", width : 100, align : 'center' ,sortable : true},
        {display: "订单编号", align : 'center' , width : 130 },
        //add by allen.qiang 20141024 退货单增加“配送日期”作为查询条件--start
        {display: "配送时间", width : 200},
        //add by allen.qiang 20141024 退货单增加“配送日期”作为查询条件--end
        {display: "会员名", width : 100},
        {display: "联系人", width : 100},
        {display: "手机号码", width : 100},
        {display: "退货原因", width : 120},
        {display: "配送站", width : 100},
        {display: "创建人", width : 80},
        {display: "创建时间", width : 150},
        {display: "备注", width : 300},
        {display: "审核人", width : 80},
        {display: "审核时间", width : 150},
        {display: "收货人", width : 80},
        {display: "收货时间", width : 150},
        {display: "取消人", width : 80},
        {display: "取消时间", width : 150}
    ],
    sortname: "return_no",
    sortorder: "desc",
    usepager: true,
    rp: 10,
    useRp: true,
    showTableToggleBtn: true,
    autoload: true,
    onSubmit: function() {
        var dt = $('#search_form').serializeArray();
        $("#flex").flexOptions({params: dt});
        return true;
    }
});

var bill = {

    return_no: '',

    search: function() {
        var dt = $("#search_form").serializeArray();
        $("#flex").flexOptions({newrp: 1, params: dt}).flexReload();
    },

    load: function() {
        $("#flex").flexReload();
    },

    clear : function (){
        $(".form-control").val('');
        $("#second_id").val('');
        $("#third_id").val('');
        $("#return_status").val(-1);
        this.search();
    },
    timeClear1: function() {
        $('#startDate').val('');
        $('#endDate').val('');
    },
    timeClear2: function() {
        $('#auditStartDate').val('');
        $('#auditEndDate').val('');
    },
    //add by allen.qiang 20141023 退货单增加“配送日期”作为查询条件--start
    timeClear3: function() {
        $('#sendDate').val('');
    },
    //add by allen.qiang 20141023 退货单增加“配送日期”作为查询条件--end

    //订单详情
    billview: function( bill_no ) {
        window.open('/quanliadmin/app/bill/billSearch.pscript?operFlg=9&bill_no=' + bill_no);
    },

    view: {

        open: function( return_no, operFlg ) {

            bill.return_no = return_no;
            this.operFlg = operFlg;

            E.ajax_get({
                url: '/invokingAjax-backend/bill/billReturn.ajax?operFlg=7&xjx=none',
                data: {
                    return_no: return_no
                },
                call: 'bill.view.result'
            });

        },

        result: function( o ) {

            if (o.code == 200) {

                var return_obj = o.data;

                var html = '<div class="panel panel-default form-horizontal">';
                html += '<div class="panel-heading">退货单信息</div>';
                html += '<div class="panel-body">';

                html += '<div class="form-group">';
                html += '<label class="col-sm-2 control-label">退货单编号</label>';
                html += '<div class="col-sm-10">';
                html += '<p class="form-control-static">' + return_obj.return_no + '</p>';
                html += '</div>';
                html += '</div>';

                html += '<div class="form-group">';
                html += '<label class="col-sm-2 control-label">订单号</label>';
                html += '<div class="col-sm-10">';
                html += '<p class="form-control-static">' + return_obj.bill_code + '</p>';
                html += '</div>';
                html += '</div>';

                if (return_obj.return_reason_2 == null || return_obj.return_reason_2 == 'null') {
                    return_obj.return_reason_2 = '';
                }

                html += '<div class="form-group">';
                html += '<label class="col-sm-2 control-label">退货原因</label>';
                html += '<div class="col-sm-3">';
                html += '<p class="form-control-static">' + return_obj.return_reason_1 + '</p>';
                html += '</div>';
                html += '<label class="col-sm-1 control-label">内容</label>';
                html += '<div class="col-sm-4">';
                html += '<p class="form-control-static">' + return_obj.return_reason_2 + '</p>';
                html += '</div>';
                html += '</div>';

                html += '<div class="form-group">';
                html += '<label class="col-sm-2 control-label">问题描述</label>';
                html += '<div class="col-sm-10">';
                html += '<p class="form-control-static">' + return_obj.return_memo + '</p>';
                html += '</div>';
                html += '</div>';

                html += '<div class="form-group">';
                html += '<label class="col-sm-2 control-label">商品返回方式</label>';
                html += '<div class="col-sm-10">';
                html += '<p class="form-control-static">' + return_obj.goods_return_type_name + '</p>';
                html += '</div>';
                html += '</div>';

                if(return_obj.coupon){
                    $.each(return_obj.coupon,function(key,value){
                        if(!E.isEmpty(value.coupon_code)){
                            html += '<div class="form-group">';
                            html += '<label class="col-sm-2 control-label">优惠券</label>';
                            html += '<div class="col-sm-10">';
                            html += '<p class="form-control-static">' + value.coupon_name + '('+ value.coupon_code +')' + '</p>';
                            html += '</div>';
                            html += '</div>';
                        }
                    });
                }
                if(return_obj.card){
                    $.each(return_obj.card,function(key,value){
                        if(!E.isEmpty(value.card_no)){
                            html += '<div class="form-group">';
                            html += '<label class="col-sm-2 control-label">现金卡</label>';
                            html += '<div class="col-sm-10">';
                            html += '<p class="form-control-static">' + value.card_name + '('+ value.card_no +')' + '</p>';
                            html += '</div>';
                            html += '</div>';
                        }
                    });
                }

                if(return_obj.pay){
                    $.each(return_obj.pay,function(key,value){
                        html += '<div class="form-group">';
                        html += '<label class="col-sm-2 control-label">'+value.payTypeName+'</label>';
                        html += '<div class="col-sm-10">';
                        html += '<p class="form-control-static">' + value.return_pay + '</p>';
                        html += '</div>';
                        html += '</div>';
                    });
                }

                if (return_obj.goods_return_type == 2) {
                    var addr = return_obj.pick_province + return_obj.pick_city + return_obj.pick_county + return_obj.pick_address;
                    html += '<div class="form-group">';
                    html += '<label class="col-sm-2 control-label">取货地址</label>';
                    html += '<div class="col-sm-10">';
                    html += '<p class="form-control-static">' + addr + '</p>';
                    html += '</div>';
                    html += '</div>';
                }

                html += '<div class="form-group">';
                html += '<label class="col-sm-2 control-label">联系人姓名</label>';
                html += '<div class="col-sm-10">';
                html += '<p class="form-control-static">' + return_obj.custName + '</p>';
                html += '</div>';
                html += '</div>';

                html += '<div class="form-group">';
                html += '<label class="col-sm-2 control-label">手机号码</label>';
                html += '<div class="col-sm-10">';
                html += '<p class="form-control-static">' + return_obj.mobile + '</p>';
                html += '</div>';
                html += '</div>';
                html += '</div>';
                html += '</div>';

                html += '<div class="panel panel-default">';
                html += '<div class="panel-heading">退货商品</div>';
                html += '<table class="table">';
                html += '<thead>';
                html += '<tr>';
                html += '<th width="180">商品编号</th>';
                html += '<th width="*">商品名称</th>';
                html += '<th width="220">规格</th>';
                html += '<th width="80">退货数量</th>';
                html += '</tr>';
                html += '</thead>';
                html += '<tbody>';
                $.each(return_obj.return_goods, function(k, v) {
                    html += '<tr>';
                    html += '<td>' + v.goodsID + '</td>';
                    html += '<td>' + v.goodsName + '</td>';
                    html += '<td>' + v.spec + '</td>';
                    html += '<td class="tac">' + v.goods_amount + '</td>';
                    html += '</tr>';
                });
                html += '</tbody>';
                html += '</table>';
                html += '</div>';

                if (this.operFlg == 0) {

                    E.popup.open({
                        title: '服务单详情',
                        content: html,
                        css: 'width: 800px;'
                    });

                } else if(this.operFlg == 3){

                    E.popup.open({
                        title:  '收货确认',
                        content: html,
                        css: 'width: 800px;',
                        btnName:  '确认收货',
                        btnCall: 'bill.receiving.execute();'
                    });

                }else {

                    E.popup.open({
                        title: this.operFlg == 2 ? '审核退货单' : '取消退货单',
                        content: html,
                        css: 'width: 800px;',
                        btnName: this.operFlg == 2 ? '审核退货单' : '取消退货单',
                        btnCall: this.operFlg == 2 ? 'bill.audit.execute();' : 'bill.cancel.execute();'
                    });

                }

            } else {
                E.alert(o.message);
            }

        }

    },

    cancel: {

        execute: function() {
            E.loadding.open('正在取消退货单，请稍候...');
            E.ajax_post({
                url:  '/invokingAjax-backend/bill/billReturn.ajax?operFlg=101',
                data: {
                    return_no: bill.return_no
                },
                call: 'bill.cancel.result'
            });
        },

        result: function( o ) {

            E.loadding.close();
            if (o.code == 200) {
                E.alert('取消成功', 2);
                bill.load();
                E.popup.close();
            } else {
                E.alert(o.message);
            }

        }

    },


};

$('#startDate').datepicker();
$('#endDate').datepicker();
$('#auditStartDate').datepicker();
$('#auditEndDate').datepicker();
//add by allen.qiang 20141023 退货单增加“配送日期”作为查询条件--start
$('#sendDate').datepicker();
//add by allen.qiang 20141023 退货单增加“配送日期”作为查询条件--end

</script>
<script type="text/javascript" src="/framework/ebsig/js/item.js"></script>
<script type="text/javascript">
    get_second_item(14);
</script>

</body>
</html>